<?php
namespace app\webapp\controller;
use think\Controller;
use mylib\Jssdk;

class Index extends Controller
{
    public function index()
    {
        $jssdk = new Jssdk("wxa356ba6c939fc2c1", "7941b1ec920c3f42b28b50facb958d38");
        $signPackage = $jssdk->GetSignPackage();

        //宠物品种
        $varieties = db('varieties')->select();

        //宠物资讯
        $informatioi = db('informatioi')->select();

        //广告图
        $banner = db('banner')->select();

        $data = [
            'signPackage' => $signPackage,
            'varieties' => $varieties,
            'informatioi' => $informatioi,
            'banner' => $banner,
        ];

        $this->assign($data);
        return view('index');
    }

    public function detail()
    {
        $id = input('id');
        $varieties = db('varieties')->where('v_id',$id)->find();
        $varieties = json_encode($varieties);
        echo $varieties;
    }

    public function new_information()
    {
        $id = input('id');
        $new_information = db('informatioi')->where('i_id',$id)->find();
        $new_information = json_encode($new_information);
        echo $new_information;
    }
}
